package com.chb.memento;

/**
 * @author chihb
 * @create-time 2024/10/26 8:45
 * @description
 */
public class Test {
    public static void main(String[] args) {
        Memento memento = new Memento();
        Caretaker caretaker = new Caretaker();
        memento.setState("打开冰箱");
        caretaker.add(memento.saveStateToOrder());
        memento.setState("将大象装入冰箱");
        caretaker.add(memento.saveStateToOrder());
        memento.setState("关闭冰箱");
        caretaker.add(memento.saveStateToOrder());
        memento.getStateFromOrder(caretaker.get(0));
        System.out.println(memento.getState());
        memento.getStateFromOrder(caretaker.get(1));
        System.out.println(memento.getState());
        memento.getStateFromOrder(caretaker.get(2));
        System.out.println(memento.getState());
    }
}
